Skip to content

feat: findDecompressedSize + frameHeaderSize, dedup content-size checks#30

Merged
dfa1 merged 1 commit into
mainfrom
feat/find-decompressed-size
Jun 27, 2026
Merged

feat: findDecompressedSize + frameHeaderSize, dedup content-size checks#30
dfa1 merged 1 commit into
mainfrom
feat/find-decompressed-size

Conversation

@dfa1

@dfa1 dfa1 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

What

Two more frame-inspection readers on ZstdFrame, plus a small refactor:

  • ZstdFrame.decompressedSize(byte[] / MemorySegment) — exact combined decompressed size of all concatenated frames, summed from each header. Throws if any frame omits its size. Complements decompressedBound (upper bound). Binds ZSTD_findDecompressedSize.
  • ZstdFrame.headerSize(byte[] / MemorySegment) — size of a frame header from just its leading bytes (as few as 5), without a full parse. Binds ZSTD_frameHeaderSize.
  • Zstd.requireStoredContentSize(long) — extracted the CONTENTSIZE_UNKNOWN / CONTENTSIZE_ERROR sentinel handling that was copy-pasted across 3 call sites, and unified the drifted error message ("not valid zstd data" vs "not a valid zstd frame").

Not bound: ZSTD_getDecompressedSize

Deprecated, and blends empty/unknown/error into 0 — the exact ambiguity ZSTD_getFrameContentSize (already bound as Zstd.decompressedSize) was added to fix. Binding a strictly-worse deprecated call adds nothing.

Tests

New ZstdFrameTest.DecompressedSize (single frame, concatenated sum, segment parity, unknown-size frame throws, garbage) and ZstdFrameTest.HeaderSize (matches parsed header, computed from 5-byte prefix, segment parity, too-short rejected). 221 unit + 81 integration green, javadoc + checkstyle clean.

Notes

  • docs/supported.md: frame inspection 10 → 12/13.
  • CHANGELOG.md Unreleased updated.

🤖 Generated with Claude Code

… checks

Adds two frame-inspection readers on ZstdFrame:
- decompressedSize(byte[]/MemorySegment) — exact combined decompressed size of
  all concatenated frames, summed from each header (throws if any frame omits
  its size). Complements decompressedBound (upper bound). Binds
  ZSTD_findDecompressedSize.
- headerSize(byte[]/MemorySegment) — size of a frame header computed from just
  its leading bytes (as few as 5), without a full parse. Binds
  ZSTD_frameHeaderSize.

Extracts Zstd.requireStoredContentSize(long) for the CONTENTSIZE_UNKNOWN /
CONTENTSIZE_ERROR sentinel handling that was copy-pasted across three call
sites, and unifies the drifted error message ("not valid zstd data" vs "not a
valid zstd frame") to one.

ZSTD_getDecompressedSize intentionally not bound: deprecated, and blends
empty/unknown/error into 0 — the ambiguity ZSTD_getFrameContentSize (already
bound as Zstd.decompressedSize) was added to fix.

docs/supported.md: frame inspection 10 -> 12/13. CHANGELOG updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dfa1 dfa1 merged commit 25737ae into main Jun 27, 2026
1 check passed
@dfa1 dfa1 deleted the feat/find-decompressed-size branch June 27, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant